package com.aigc.sclassroom.controller;

import com.aigc.sclassroom.pojo.Class;
import com.aigc.sclassroom.pojo.Result;
import com.aigc.sclassroom.service.ClassService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@RestController
@RequestMapping("/class")
public class ClassController {
    @Autowired
    private ClassService classService;

    @PostMapping("/addAndGet")
    public Result addAndGet(@RequestParam Long courseManageId) {
        Class insertedClass = classService.addAndGet(courseManageId);
        return Result.success(insertedClass);
    }

    //新增课节
    @PostMapping
    public Result add(@RequestParam Long courseManageId) {
        classService.add(courseManageId);
        return Result.success();
    }

    //查询该课程所有课节
    @GetMapping
    public Result<List<Class>> selectAll(Long courseManageId) {
        List<Class> cs = classService.selectAllByCourseManageId(courseManageId);
        return Result.success(cs);
    }
}